home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac100% 1998 November
/
MAC100-1998-11.ISO.7z
/
MAC100-1998-11.ISO
/
オンラインソフト定点観測
/
ユーティリティ
/
Mops 3.2.sea
/
Mops 3.2
/
Mops source
/
Module source
/
zExtrasmod.txt
< prev
next >
Wrap
Text File
|
1998-06-13
|
6KB
|
265 lines
¥ This module implements a number of words that we need only at compile time,
¥ or only in the Mops development environment.
false value LOG_THERE?
false value SRC_THERE?
false value USE_MOD?
false value QE? ¥ set true if we know QE is running
:class FSSpec super{ object }
68k_record
{ int vRefNum
var parID
64 bytes filename
}
:m getVref: get: vRefNum ;m
:m getDirID: get: parID ;m
:m setVref: put: vRefNum ;m
:m setDirID: put: parID ;m
:m name: 64 min addr: fileName >str255 drop ;m
:m getName: addr: fileName count ;m
:m NEW:
get: vRefNum get: parID addr: filename ^base
FSMakeFSSpec ;m
;class
FSSpec FS
objPtr THEMOD class_is module
window DW
file SRC
file QEF
0 value MK_CFA
0 value TOPDIR
0 value TOPDATE
: CHK_DATE
getFileInfo: src OK? src 76 + @
use_mod?
IF
base: theMod @
ELSE
mk_cfa 14 + @ ?dup NIF -1 THEN
THEN
u>
IF
3 beep cr msg# 76 ¥ "Source later than compiled version"
THEN ;
¥ ?OPEN_IN_QE is exported. It sees if the passed-in file can be opened
¥ in Quick Edit via an AppleEvent. The value QE? is left indicating
¥ the result. It's not a serious problem if we can't find the file, but
¥ it's nice if we can.
: ?OPEN_IN_QE { ^file -- }
false -> QE? ¥ in case another error comes up!
getname: [ ^file ] name: FS
0 setVref: FS 0 setDirID: FS
new: FS
IF ¥ An error occured. The file might have been opened via
¥ standard file. In this case, topDir will be set. Let's
¥ try...
getName: [ ^file ]
name: FS
0 setVref: FS topDir setDirID: FS
new: fs ?EXIT ¥ Out if we still can't find it
THEN
getName: FS name: qef
getVref: FS setVref: qef
getDirID: FS setDirID: qef
qef 0 0 openFile: tQE ?EXIT
¥ If AE send failed, maybe QE isn't there at all!
true -> QE? ;
: (OPEN_SRC)
2dup put: $tmp name: src
openReadOnly: src ¥ Get full pathname.
?error 66 ¥ "couldn't find source file"
src ?open_in_QE
close: src drop
QE? not ?error 67 ¥ "Quick Edit not open or sys7 not running"
¥ use_mod?
¥ NIF
¥ mk_cfa 10 + @ setDirID: src
¥ THEN
¥ src ?open_in_QE
;
: SRC_NAME
mk_cfa 18 + count ;
: OPEN_SRC
src_name (open_src) ;
: OPEN_SRC_IN_MOD
txtName: theMod (open_src) ;
¥ The following words are used in conjunction with Quick Edit.
¥ EDIT is exported. It opens the given file in QE if possible.
¥ Usage: edit xxxx
: EDIT
setName: src
openReadOnly: src ¥ Get full pathname.
?error 66 ¥ "couldn't find source file"
src ?open_in_QE
close: src drop
QE? not ?error 67 ¥ "Quick Edit not open or sys7 not running"
;
¥ OPENSOURCE is exported. This word is called from QE, so we can assume
¥ QE is there. QE is asking us to identify the source file for the given
¥ word, and then call QE back to open that file. The format of the string
¥ sent from QE (located in QEstr) is FindSource xxxxx. At this point
¥ we're EVALUATEing, and have parsed the FindSource, so we can now
¥ simply call DEFINED?.
¥ Note: this word is also called LOCATE, which I now think is a better name.
: OPENSOURCE
defined?
IF locate_src
ELSE
1 beep
reset: QEstr
7 skip: QEstr ¥ skip over "locate ", and hope "opensource" wasn't
¥ what was called!
get: QEstr type space ." not defined!!"
THEN ;
¥ def?? is exported. It's needed by the QE special menu item def??
: def?? ¥ 19Dec93 DBH slightly changed to show us the word in question and
¥ display the answer
reset: QEstr
6 skip: QEstr ¥ skip over def??
get: QEstr type space
defined?
nip
IF ." defined"
ELSE ." not defined!!"
THEN ;
: MOVE_CURS { pos -- }
QE? 0EXIT
qef pos dup openFile: tQE 0EXIT
false -> QE? ¥ failed - assume QE has gone away
;
¥ ========== end of QE-related words =============
: (FINDMK) ¥ ( cfa 0 -- )
drop dup -> mk_cfa 2- w@ $ BC41 = ¥ is it a marker?
IF ¥ yes
mk_cfa w@ 1 = ¥ is it a file marker?
-> endTrav?
THEN
;
: FIND_MARK? ¥ ( start-addr -- )
['] (findmk) 0 rot trav-from
endTrav? ;
: LOCATE_SRC { theCfa -- } ¥ Exported. Opens source window for given
¥ definition, if possible.
use_mod?
NIF theCfa find_mark? 0EXIT
THEN
use_mod?
IF open_src_in_mod
false -> use_mod? ¥ For next time
ELSE
open_src
THEN
QE? IF theCfa >name n>count find: tQE drop THEN ;
: USE_MODULE ¥ ( ^mod -- )
-> theMod true -> use_mod? ;
¥ ======== Code for loading and reloading =========
(* ***
¥ SAVE-LOAD is a smarter variant of mark_file which we use
¥ to put a file mark in the dic at the start of each load.
¥ It includes the dirID, whether logged, and the date/time
¥ loaded.
: SAVE-LOAD
getName: topFile put: $tmp bl +: $tmp reset: $tmp
& : <chsearch: $tmp negate skip: $tmp
get: $tmp
sHdr
file-mark codeW, ¥ file-mark is the "handler code"
topDir code,
topDate code,
release: $tmp ;
: LOADIT { ¥ svCurs -- }
¥ purge_init_actions
curs -> svCurs -curs
getFileInfo: topFile NIF topFile 76 + @ ELSE 0 THEN -> topDate
clear: topFile
topDir setDirID: topFile
save-load
MBcomp LdFromMod drop: loadFile
svCurs -> curs
;
*** *)
: L ¥ Load
pushNew: loadfile
'type TEXT 1 stdget: topfile
IF getDirID dup setDirID: topFile -> topDir
(load)
ELSE
clear: loadfile
THEN ;
: FM ¥ Forget to mark
CDP find_mark? not abort" No mark!"
mk_cfa ex-gen
;
: RL
CDP find_mark? not abort" Nothing loaded!"
pushnew: loadfile
src_name name: topFile ¥ using full path name
¥ stored after the marker
mk_cfa ex-gen ¥ forget back to the marker
(load)
;